Quick yank and paste
*I propose making this the "copy/paste mappings" tip, and merge in the various other attempts. *When finished, rename this tip (and maybe some of the others). *Possibly have a section for Windows Ctrl-C/X/V stuff, and another for other approaches. *For Windows Ctrl-C/X/V, is there any need for a tip other than to explain about mswin.vim? *The wiki should explain how to use Vim properly, so a bunch of tips on making Vim imitate Notepad are not helpful IMHO. However, one tip on Ctrl-C/X/V is warranted (particularly now they are "standard" on Mac + Windows + Linux). *Might keep some different approaches, but perhaps will just pick what appears to be the "best". *Use following list for related tips (probably will not merge them to here, but may find some info in them that could be moved to this tip). Copy/cut/paste *356 Quick yank and paste Copy/paste mappings (this tip) *312 Copy, cut and paste Copy/paste without selection *960 Copy an Entire Buffer to the Clipboard Copy All System clipboard *21 Easy pasting to Windows applications :set clipboard=unnamed, :set go+=a *687 Mac OS X clipboard sharing *984 Accessing the system clipboard *1511 In line copy and paste to system clipboard Mac OS X? Content from VimTip356 (this tip) Since I didn't want to interfere with the standard Vim mappings I removed all the , , etc. mappings found in the default vimrc. But quickly copy-pasting text is a must, so I added the following keymaps. This is very simple, but it works like a charm. vmap "ay nmap "aP imap "ap nmap "ayiw Comments I found the insertion mapping faulty: its behavior depended on whether I was at the end of the line. The following work well for me: vmap "py nmap "pyiw vmap "pp nmap "pP imap "ppa Content from tip 1387 (now removed; content to be merged here) Having replaced Notepad with gvim, these are my preferred editing shortcuts: " Copy to 'clipboard registry' vmap "*y " Select all text nmap ggVG Comments Have you seen vim70/mswin.vim, it comes with Vim 7.0 (and prior versions). It sets up a bunch of behavior that makes Vim work nice with Windows. Just source it in your vimrc. It's worth reading through for some ideas if you don't want to use the entire thing. Content from tip 1528 (now removed; content to be merged here) Easy copy and paste in Vim: " normal copy/paste vmap yi vmap di imap pi imap ddi map imap ui How it works: Select something in visual mode. Then Ctrl-c (copy), Ctrl-x (cut). After the operation you are in insert mode. So just navigate to the place where you want to paste and do Ctrl-v When in insert mode Ctrl-y deletes the current line, Ctrl-z undo last change. To make interaction with other applications more intuitive, see Easy_pasting_to_Windows_applications. Todo Need to state whether this is for a particular operating system. Does it work with the system clipboard? If not, is it useful? See for usage of mswin.vim. Most installs of Vim on Windows use mswin.vim. In that case, Ctrl-C, Ctrl-X, Ctrl-V, Ctrl-Z just behave as a Windows user would expect, and the tip as now written has no point. If using gvim without mswin.vim (a good idea), look at the Edit menu for the recommended keys. If wanting the mswin.vim key mappings, is there a reason to use this tip rather than mswin.vim? Content from tip 866 (now removed; content to be merged here) " -- cut (goto visual mode and cut) imap vgG vmap "*xi " -- copy (goto visual mode and copy) imap vgG vmap "*yi " -- copy all imap gggHG vmap gggHGi " -- paste nm \\paste\\ "=@*.'xy'gPFx"_2x:echo imap x\\paste\\"_s vmap "-cx\\paste\\"_x Comments What's wrong with the default? In Vim 7.1, see the files distributed with Vim: *vim/vim71/macmap.vim, vim/vim71/menu.vim, vim/vim71/mswin.vim *vim/vim71/autoload/paste.vim ----